
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>人事调动管理</title>
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">
    <link rel="stylesheet" href="/css/notice/noticeManagement.css">
    <script src="/js/common/language.js"></script>

    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="../lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <style>
        table tbody td{
            text-align: left!important;
        }
        input{
            float: none;
        }
        .editAndDelete3{
            color: red;
        }
        #pagediv{
            width: 100%;
        }
        #pagediv table{
            width: 95%;
            margin-left: 1%;
        }
        #pagediv table tr:nth-child(odd){
            background-color: #F6F7F9;
        }
        #pagediv table tr:nth-child(even){
            background-color: #ffffff;
        }
        #pagediv table tr th{
            padding: 8px;
            font-size: 13pt;
            color: #2F5C8F;
            font-weight: bold;
            text-align: left;
        }
        #pagediv table tr td{
            padding: 8px;
            font-size: 11pt;
            text-align: left;
        }
        .deleteAll{
            display: inline-block;
            width: 70px;
            height: 28px;
            position: relative;
            color: #ffffff;
            border-radius: 3px;
            background: #2b7fe0;
            text-align: center;
            line-height: 28px;
            margin-left: 20px;
        }
        .newClass{
            float: right;
            width: 90px;
            height: 28px;
            background: url(../../img/file/cabinet01.png) no-repeat;
            color: #fff;
            font-size: 14px;
            line-height: 28px;
            margin: 2% 4% 0 0;
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="navigation">
    <img src="/img/commonTheme/${sessionScope.InterfaceModel}/gonggaoguanli.png" alt="">
    <h2>人事调动管理</h2>
    <div class="newClass" id="newClass">
            <span style="margin-left: 30px;">
                <img style="margin-right: 4px;margin-left: -14px;margin-bottom: 4px;" src="../../img/mywork/newbuildworjk.png" alt="">
                新建
            </span>
    </div>
</div>
<div id="pagediv">
    <table cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
        <thead>
        <tr>
            <th style="width: 40px;">选择</th>
            <th>调动人员</th>
            <th>调动类型</th>
            <th>调动日期</th>
            <th>调动生效日期</th>
            <th>审核状态</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="trList">

        </tbody>

    </table>

    <div class="right" style="margin-right: 10%;">
        <!-- 分页按钮-->
        <div class="M-box3" id="dbgz_pagesd"></div>
    </div>
</div>
<script type="text/javascript">
    var type = $.GetRequest().type;
    var userId= decodeURI($.GetRequest().userId);
    //新建
    $("#newClass").on("click",function(){
       /* if(type!=undefined){
            window.location.href="/hr/manage/tansferNewedit?type=1&userId="+userId;
        }else{

        }*/
        window.location.href="/hr/manage/tansferNewedit";
    })
    $(function () {
        dataInit()

//        删除
        $('#trList').on('click','.deleteData',function () {
            var dataId=$(this).parents('tr').attr('data-id');
            deleteData(dataId);
        })

//        点击编辑
        $('#trList').on('click','.editData',function () {
            var dataId=$(this).parents('tr').attr('data-id');
            if(type!=undefined){
                parent.$('[name="notices"]').attr('src','/hr/manage/tansferNewedit?type=1&userId='+userId+'&transferId='+dataId);
            }else{
                parent.$('[name="notices"]').attr('src','/hr/manage/tansferNewedit?transferId='+dataId);
            }

        })
//        点击全选
        $('#trList').on('click','.checkedAll',function () {
            var state=$(this).prop('checked');
            if(state == true){
                $(this).prop('checked',true);
                $('input[name="checkChild"]').prop('checked',true);
            }else{
                $(this).prop('checked',false);
                $('input[name="checkChild"]').prop('checked',false);
            }
        })
//        点击复选框
        $('#trList').on('click','input[name="checkChild"]',function () {
            var state=$(this).prop('checked');
            if(state == true){
                $(this).prop('checked',true);
            }else {
                $('#trList').find('.checkedAll').prop('checked',false);
                $(this).prop('checked',false);
            }
            var childCheck=$('#trList').find('input[name="checkChild"]');
            for(var i=0;i<childCheck.length;i++){
                var stateChild=$(childCheck[i]).prop('checked');
                if(state != stateChild){
                    return
                }
            }
            $('#trList').find('.checkedAll').prop('checked',state);
        })
//        点击删除按钮
        $('#trList').on('click','.deleteAll',function () {
            var deleteId='';
            $('#trList').find('input[name="checkChild"]:checked').each(function () {
                deleteId+=$(this).parents('tr').attr('data-id')+',';
            })
            deleteData(deleteId);
        })
//          点击详情
        $('#trList').on('click','.detailsData',function () {
            var dataId=$(this).parents('tr').attr('data-id');
            $.popWindow('/hr/manage/tansferDetail?transferId='+dataId, '人事调动信息详情', '0', '0', '1300px', '600px');
        })


    })


    function dataInit() {
        var ajaxPage={
            data:{
                page:1,//当前处于第几页
                pageSize:5,//一页显示几条
                useFlag:true,
            },
            page:function () {
                var me=this;
                $.ajax({
                    type:'get',
                    url:'/hr/manage/selectHrTransfers',
                    dataType:'json',
                    data:me.data,
                    success:function(res){
                        var str='';
                        var str_s='';
                        var datas=res.obj;
                        if(datas.length > 0){
                            for(var i=0;i<datas.length;i++){
                                str+='<tr data-id="'+datas[i].transferId+'">' +
                                    '<td><input type="checkbox" name="checkChild"></td>' +
                                    '<td>'+dataundefined(datas[i].transferPerson)+'</td>' +
                                    '<td>'+dataundefined(datas[i].transferType)+'</td>' +
                                    '<td>'+dataundefined(datas[i].transferDate)+'</td>' +
                                    '<td>'+dataundefined(datas[i].transferEffectiveDate)+'</td>' +
                                    '<td>'+checkAudit(datas[i].auditState)+'</td>' +
                                    '<td>'+dataundefined(datas[i].remark)+'</td>' +
                                    '<td>' +
                                    '<a href="javascript:;" class="detailsData">查看详情</a>' +
                                    '<a href="javascript:;" class="editData" style="margin: 0 10px;">编辑</a>' +
                                    '<a href="javascript:;" class="deleteData" style="color: red">删除</a>' +
                                    '</td>' +
                                    '</tr>'
                            }
                            str_s='<tr><td colspan="8"><label style="cursor: pointer;"><input style="cursor: pointer;" type="checkbox" class="checkedAll"><span>全选</span></label><a href="javascript:;" class="deleteAll"><img src="/img/file/icon_fileDelete.png" style="margin-right: 4px;margin-left: -2px;margin-bottom: 3px;" alt="">删除</a></td></tr>'
                        }

                        $('#trList').html(str+str_s);
                        me.pageTwo(res.totleNum,me.data.pageSize,me.data.page);


                    }
                });

            },
            pageTwo:function (totalData, pageSize,indexs) {
                var mes=this;
                $('#dbgz_pagesd').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    jump: true,
                    coping: true,
                    homePage:'',
                    endPage: '',
                    current:indexs||1,
                    callback: function (index) {
                        mes.data.page=index.getCurrent();
                        mes.page();
                    }
                });
            }
        }
        if(userId!='undefined'&&userId!=undefined){
            ajaxPage.data.transferPerson = userId;
        }
        ajaxPage.page();
    }
    function  checkAudit(auditState) {

        if (auditState == 1) {
            return '<span style="text-align: center;">提交离职申请</span>';
        } else if (auditState== 5) {
            return '<span style="text-align: center;">管理员审核通过</span>';
        } else if (auditState== 6) {
            return '<span style="text-align: center;">离职申请退回</span>';
        }else {
            return '<span style="text-align: center;"></span>';
        }

    }
    function dataundefined(data) {
        if(data == undefined){
            return '';
        }else {
            return data;
        }
    }
    function deleteData(data) {
        layer.confirm('确定删除该条数据吗？', {
            btn: ['确定','取消'], //按钮
            title:"删除"
        }, function(){
            //确定删除，调接口
            $.ajax({
                type:'post',
                url:'/hr/manage/deleteHrTransfers',
                dataType:'json',
                data:{
                    ids:data
                },
                success:function(res){
                    if(res.flag){
                        layer.msg('删除成功！', { icon:6});
                        dataInit()
                    }else {
                        layer.msg('删除失败！', { icon:5});
                    }

                }
            })

        }, function(){
            layer.closeAll();
        });
    }
</script>
</body>
</html>